package org.linphone.sub.treeview;

import android.view.View;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;

import org.linphone.R;

import me.texy.treeview.TreeNode;
import me.texy.treeview.base.CheckableNodeViewBinder;

/**
 * Created by Xiang on 2018/5/15.
 */

public class FirstAllList extends CheckableNodeViewBinder {
	//名称
	private TextView text_all_Select;
	//选择框
	private CheckBox check_select_all;
	//箭头图标
	private ImageView image_arrow;
	//初始化数据
	public FirstAllList(View itemView) {
		super(itemView);
		image_arrow = (ImageView) itemView.findViewById(R.id.image_arrow);
		text_all_Select = (TextView) itemView.findViewById(R.id.text_all_Select);
		check_select_all = (CheckBox) itemView.findViewById(R.id.check_select_all);
	}
	//获取选择的数据
	@Override
	public int getCheckableViewId() {
		return R.id.check_select_all;
	}
	//获取数据Id
	@Override
	public int getLayoutId() {
		return R.layout.first_all;
	}
	//绑定View
	@Override
	public void bindView(TreeNode treeNode) {
		/** 设置TextView数据，作为第一级类目 */
		String[] all = treeNode.getValue().toString().split("[$]");
		text_all_Select.setText(all[0]);
	}
	//箭头切换
	@Override
	public void onNodeToggled(TreeNode treeNode, boolean expand) {
		if(expand){
			image_arrow.setImageResource(R.mipmap.img_catergory_spinner_icon);
		}else {
			image_arrow.setImageResource(R.mipmap.img_catergory_icon);
		}
	}

}
